<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use DB;
class Twobar extends Model
{
    
    protected $table = 'two_level_bar';
    
    public function ajaxIndex()
    {
         $draw = request('draw', 1);/*获取请求次数*/
        $start = request('start', config('admin.global.list.start')); /*获取开始*/
        $length = request('length', config('admin.global.list.length')); ///*获取条数*/
        
        $time = time();
        
        
        
        
        
        
        $sqlCount = "SELECT COUNT(*) AS `sum` FROM income";

        $count = DB::select($sqlCount);
       

       
        

       $sql = "SELECT * FROM income";

       $sql .= " ORDER BY id DESC
                LIMIT ?
                OFFSET ?";
       
           
        $list = DB::select($sql, array($length, $start));
        //return $list;
        $list = json_encode($list, true);
        $list = json_decode($list, true);
        
        
	
                
        if ($list) {
            foreach ($list as &$v) {
               
               
            }
        }
       
        return [
            'draw' => $draw,
            'recordsTotal' => $count[0]->sum,
            'recordsFiltered' => $count[0]->sum,
            'data' => $list,
        ];
    }
}
